package cn.wonderland.user.controller;

import cn.wonderland.basic.util.AjaxResult;
import cn.wonderland.user.dto.AccountLoginDto;
import cn.wonderland.user.dto.WechatBinderDto;
import cn.wonderland.user.dto.WechatDto;
import cn.wonderland.user.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    /**
     * 账号密码登录
     */
    @PostMapping("/accountLogin")
    public AjaxResult accountLogin(@RequestBody @Valid AccountLoginDto dto) {
        return loginService.accountLogin(dto);
    }

    /**
     * 微信扫码登录
     */
    @PostMapping("/wechat")
    public AjaxResult wechat(@RequestBody @Valid WechatDto dto) {
        return loginService.wechat(dto);
    }

    /**
     * 微信绑定接口
     */
    @PostMapping("/wechat/binder")
    public AjaxResult wechatBinder(@RequestBody @Valid WechatBinderDto dto) {
        return loginService.wechatBinder(dto);
    }
}
